package com.example.sunhetian.controller;


import com.example.sunhetian.entity.Dept;
import com.example.sunhetian.service.IDeptService;
import com.example.sunhetian.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ykg
 * @since 2022-12-28
 */
@ResponseBody
@RestController
@RequestMapping("/dept")
public class DeptController {
    @Resource
    private IDeptService iDeptService;
    @GetMapping
    public Result getAll(){
        List<Dept> list=iDeptService.list();
        return new Result(list);
    }
    /**删除**/
    @DeleteMapping("{deptno}")
    public Result delByid(@PathVariable Integer deptno){
        return new Result(iDeptService.removeById(deptno));
    }

    @PostMapping
    public  Result addOrUpdate(Dept dept){
        return  new Result(iDeptService.saveOrUpdate(dept));
    }

}

